package movie.test.aop;

import java.util.HashMap;
import java.util.Map;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import movie.test.as.log.service.Impl.LogServiceImpl;
import movie.test.as.user.service.impl.AdminUserServiceImpl;

@Component
@Aspect
@SuppressWarnings("unchecked")
public class LogAop {

	@Autowired
	private LogServiceImpl logServiceImpl;
	@Autowired
	private AdminUserServiceImpl adminUserServiceImpl;

	//@Pointcut("execution(* movie.test.as..*.login(..))")
	@Pointcut("execution(* movie.test.as.user.service.impl..*.loginUser(..))")
	public void testLogAop() {

	}

	@Around(value = "testLogAop()")
	public Object logSysLogin(ProceedingJoinPoint pj) {
		@SuppressWarnings("rawtypes")
		Map map = new HashMap();
		Object[] args = pj.getArgs();
		Map mapUser = (Map) args[0];
		map.put("userName", mapUser.get("userName"));
		logServiceImpl.insertLog(map);
		return map;

	}

}
